package com.aaa.java13;

import com.aaa.java04.Person;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/16 15:47
 * @description：对象集合
 * @modified By：
 * @version: 1.0
 */
public class ObjectCollection {
    public static void main(String[] args) {
        List<MyPerson> personList= new ArrayList<>();
        MyPerson person1= new MyPerson(111,"张胜",23);
        MyPerson person2= new MyPerson(123,"李四",21);
        MyPerson person3= new MyPerson(102,"王五",28);
    /*    MyPerson person4= new MyPerson(123,"赵六",28);*/
        personList.add(person1);
        personList.add(person2);
        personList.add(person3);
/*        personList.add(null);
        personList.add(null);
        personList.add(null);*/
/*        personList.add(person4);*/
        System.out.println("遍历list集合");
        for (MyPerson myPerson : personList) {
            System.out.println(myPerson.toString());
        }
       /*personList.remove(new MyPerson(123,"李四",21));*/
     /*   personList.remove(new MyPerson(123,"赵六",28));*/
        boolean contains = personList.contains(new MyPerson(123, "李四", 21));
        System.out.println(contains);
        System.out.println("删除之后");
        for (MyPerson myPerson : personList) {
            System.out.println(myPerson.toString());
        }
    }
}
